﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using AutoR.Models;
using AutoR.Services;
using Prism.Mvvm;
using Prism.Navigation;

namespace AutoR.ViewModels.Home
{
	// Token: 0x020000CE RID: 206
	public class QuestViewModel : BindableBase, INavigationAware, INavigatedAware, INavigatingAware
	{
		// Token: 0x17000121 RID: 289
		// (get) Token: 0x06000416 RID: 1046 RVA: 0x0004D265 File Offset: 0x0004B465
		private INavigationService NavigationService { get; }

		// Token: 0x17000122 RID: 290
		// (get) Token: 0x06000417 RID: 1047 RVA: 0x0004D26D File Offset: 0x0004B46D
		// (set) Token: 0x06000418 RID: 1048 RVA: 0x0004D278 File Offset: 0x0004B478
		public List<UserQuest> UserTask
		{
			[CompilerGenerated]
			get
			{
				return this.<UserTask>k__BackingField;
			}
			[CompilerGenerated]
			set
			{
				if (object.Equals(this.<UserTask>k__BackingField, value))
				{
					return;
				}
				this.<UserTask>k__BackingField = value;
				this.OnPropertyChanged(<>PropertyChangedEventArgs.UserTask);
			}
		}

		// Token: 0x06000419 RID: 1049 RVA: 0x0004D2A8 File Offset: 0x0004B4A8
		public QuestViewModel(INavigationService navigationService)
		{
			this.NavigationService = navigationService;
		}

		// Token: 0x0600041A RID: 1050 RVA: 0x0004067F File Offset: 0x0003E87F
		public void OnNavigatedFrom(INavigationParameters parameters)
		{
		}

		// Token: 0x0600041B RID: 1051 RVA: 0x0004D2B8 File Offset: 0x0004B4B8
		public void OnNavigatedTo(INavigationParameters parameters)
		{
			this.UserTask = Runtime.Game.UserTask.ToList<UserQuest>();
			foreach (UserQuest userQuest in this.UserTask)
			{
				Regex regex = new Regex("\\^\\w{17}");
				userQuest.desc = regex.Replace(userQuest.desc, "");
				regex = new Regex("\\[\\#s(\\d+)\\#n\\]");
				using (IEnumerator enumerator2 = regex.Matches(userQuest.desc).GetEnumerator())
				{
					while (enumerator2.MoveNext())
					{
						Match ma = (Match)enumerator2.Current;
						ShipConfig shipConfig = Runtime.Configs.shipCard.SingleOrDefault((ShipConfig i) => i.cid.ToString() == ma.Groups[1].Value);
						string newValue = (shipConfig != null) ? shipConfig.title : null;
						userQuest.desc = userQuest.desc.Replace(ma.Value, newValue);
					}
				}
			}
		}

		// Token: 0x0600041C RID: 1052 RVA: 0x0004067F File Offset: 0x0003E87F
		public void OnNavigatingTo(INavigationParameters parameters)
		{
		}
	}
}
